package com.designpatterns.frontcontrollerpattern;

public class FrontController
{
	private Dispatcher dispatcher;

	// 交由Spring管理的话这里就不用new了
	public FrontController()
	{
		dispatcher = new Dispatcher();
	}

	// 可加登录验证
	private boolean isAuthenticUser()
	{
		System.out.println("User is authenticated successfully.");
		return true;
	}

	private void trackRequest(String request)
	{
		System.out.println("Page requested: " + request);
	}

	public void dispatchRequest(String request)
	{
		// 记录每一个请求
		trackRequest(request);
		// 对用户进行身份验证
		if (isAuthenticUser())
		{
			dispatcher.dispatch(request);
		}
	}
}
